<?php

Class Nottification extends Connect {
    
    
    public  $all,
            $count,
            $stop,
            $text;
    
    function Nottification(){
        
    }
    
    function get(){
        $sql = "SELECT * FROM `".PREFIX_TABLE."nottification`";
        if(!$result = DBConnect::query($sql)){    
            $this->error(mysql_error());
            return false;
        }                
        $data = DBConnect::getOne( $result );
        #print_r( $data );        
        $this->all = (boolean) $data['all'];
        $this->count = $data['sended'];
        $this->stop = (boolean) $data['stoped'];
        $this->text = $data['text'];
    }
    
    function save(){
        $sql = "UPDATE `".PREFIX_TABLE."nottification` SET 
                            `text` = '".$this->text."',
                            `sended` = ".($this->count).",
                            `stoped` = '". $this->stop ."', 
                            `all` = '". ( $this->all  ) ."' " ;
        
        #print_r( (string)$sql);        
        if(!$result = DBConnect::query($sql)){
            $this->error(mysql_error());
            return false;
        }
        return true;
    }
    
    function stop(  ){
        $this->stop = 1;
    }
    function start(){
        $this->stop = 0;
    }
    function text($text){
        $this->text = $text;
    }
    function sended( $count ){
        $this->count = $count;
    }
    /**
     * 0 - 
     * 1 - 
    */
    function all( $all ){
        $this->all = $all;
    }
    
}

?>